﻿using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2.pushApi
{
    public class JobCreateFactory
    {
        private int number = 1;
        private int count = 1;
        public IJobDetail CreateIJobDetail<T>() where T : IJob
        {
            return JobBuilder.Create<T>().WithIdentity("yuwei" + (number++), "group1").Build();
        }

        public ITrigger CreateTrigger(String str)
        {
            return TriggerBuilder.Create()
                                          .WithIdentity("a" + (count++), "group1")
                                          .StartNow()
                                                                  //现在开始
                                          .WithCronSchedule(str)    //时间表达式，5秒一次       
                                                                    //不间断重复执行
                                          .Build();
        }
    }
}
